<template>
  <div v-if="visible" class="custom-modal">
    <div class="modal-overlay" @click="handleCancel"></div>
    <div class="modal-content">
      <div class="modal-header">
        <h3>资产详情</h3>
        <button class="close-btn" @click="handleCancel">×</button>
      </div>
      <div class="modal-body">
        <div class="detail-section">
          <h4>基础信息</h4>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">资产编码：</span>
              <span class="value">{{ assetDetail.assetCode || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">资产名称：</span>
              <span class="value">{{ assetDetail.assetName || '-' }}</span>
            </div>
          </div>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">资产类型：</span>
              <span class="value">{{ assetDetail.type_dictText || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">资产状态：</span>
              <span class="value">{{ assetDetail.status_dictText || '-' }}</span>
            </div>
          </div>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">负责人：</span>
              <span class="value">{{ assetDetail.chargePerson || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">联系电话：</span>
              <span class="value">{{ assetDetail.chargeMobile || '-' }}</span>
            </div>
          </div>
        </div>

        <div class="detail-section" v-if="assetDetail.type === '1'">
          <h4>空间资产信息</h4>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">空间类型：</span>
              <span class="value">{{ assetDetail.spaceType_dictText || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">空间子类：</span>
              <span class="value">{{ assetDetail.spaceSubtype_dictText || '-' }}</span>
            </div>
          </div>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">详细地址：</span>
              <span class="value">{{ assetDetail.place || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">建筑面积：</span>
              <span class="value">{{ assetDetail.buildingArea || '-' }} ㎡</span>
            </div>
          </div>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">可租面积：</span>
              <span class="value">{{ assetDetail.rentableArea || '-' }} ㎡</span>
            </div>
            <div class="detail-item">
              <span class="label">楼层信息：</span>
              <span class="value">{{ assetDetail.floorInfo || '-' }}</span>
            </div>
          </div>
        </div>

        <div class="detail-section" v-if="assetDetail.type === '2'">
          <h4>设备资产信息</h4>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">设备分类：</span>
              <span class="value">{{ assetDetail.equipmentCategory_dictText || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">存放位置：</span>
              <span class="value">{{ assetDetail.place || '-' }}</span>
            </div>
          </div>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">品牌：</span>
              <span class="value">{{ assetDetail.brand || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">规格型号：</span>
              <span class="value">{{ assetDetail.model || '-' }}</span>
            </div>
          </div>
          <div class="detail-row">
            <div class="detail-item">
              <span class="label">制造商：</span>
              <span class="value">{{ assetDetail.manufacturer || '-' }}</span>
            </div>
            <div class="detail-item">
              <span class="label">出厂日期：</span>
              <span class="value">{{ assetDetail.factoryDate || '-' }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button class="cancel-btn" @click="handleCancel">关闭</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    assetDetail: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handleCancel() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
}

.modal-content {
  position: relative;
  background: #0a1f44;
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  width: 800px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
}

.modal-header {
  background: #102a5c;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1e3a5f;
}

.modal-header h3 {
  color: #d4e1f5;
  margin: 0;
  font-size: 18px;
}

.close-btn {
  background: none;
  border: none;
  color: #8ba6d9;
  font-size: 20px;
  cursor: pointer;
}

.close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  color: #d4e1f5;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  margin-bottom: 10px;
  color: #a9c4e8;
  border-bottom: 1px solid #1e3a5f;
  padding-bottom: 5px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.detail-item {
  flex: 1;
  margin-right: 10px;
}

.label {
  font-weight: bold;
  color: #a9c4e8;
}

.value {
  color: #d4e1f5;
}

.modal-footer {
  background: #102a5c;
  padding: 16px;
  border-top: 1px solid #1e3a5f;
  text-align: right;
}

.cancel-btn {
  background: #1e3a5f;
  color: #d4e1f5;
  border: 1px solid #2a4f7a;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.cancel-btn:hover {
  background: #2a4f7a;
}
</style>
